<?php

/**
 * ctrl_page_adodb_browser
 *
 * @since ADD ADOdb Admin 0.0
 */
CLASS ctrl_tpl_adodb_admin EXTENDS ctrl_tpl_page {

   /**
    * Query Mode
    *
    * @since ADD-ADOdb-Admin 0.0
    */
   public function pre_mode_process($gpc) {

      session_start();

      if ( !$this instanceof ctrl_page_login ) {
         adodb_user::require_logged_in();
      }
   }

/**
 * View File Path
 *
 * @since ADD ADOdb Admin 0.0
 */
   public static function view_filepath() {
      return "pages/".static::view_basename().'.tpl';
   }

   /**
    * Print Response Ajax Support
    *
    * @since ADD ADOdb Admin 0.0
    */
   public function print_response($data) {
      if (empty($_REQUEST['ajax'])) {
         echo parent::print_response($data);
      }
      else {
         $this->content_type('text/plain');
         add::$handle_shutdown = false;
         if (empty($this->data['json_data']))
            $this->data['json_data'] = array();

         if ($this->data['error_message'] && empty($this->data['json_data']['error_message']))
            $this->data['json_data']['error_message'] = $this->data['error_message'];

         echo json_encode($this->data['json_data']);
      }
   }
}